package com.aegis.api.auth.manage;

import com.aegis.api.auth.context.FeignContext;

import java.util.Optional;

/**
 * @Author wuweixin
 *
 * @Version 1.0
 * @Descritube
 */
public class FeignManager {

    private final static ThreadLocal<FeignContext> FEIGN_CONTEXT_THREAD_LOCAL = new ThreadLocal<>();

    public static void setUrl(String url) {
        FeignContext feignContext = Optional.ofNullable(FEIGN_CONTEXT_THREAD_LOCAL.get()).orElse(new FeignContext());
        feignContext.setUrl(url);
        FEIGN_CONTEXT_THREAD_LOCAL.set(feignContext);
    }

    public static FeignContext getFeignContext() {
        return FEIGN_CONTEXT_THREAD_LOCAL.get();
    }

    public static void clear() {
        FEIGN_CONTEXT_THREAD_LOCAL.remove();
    }


}
